<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<title>订单管理</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<link rel="stylesheet" href="statics/css/bootstrap.css">
		<link rel="stylesheet" href="statics/css/bootstrap-datetimepicker.css">
		<script src="https://cdn.bootcss.com/holder/2.9.4/holder.min.js"></script>
		<script type="text/javascript" src="statics/js/jquery.js"></script>
		<script type="text/javascript" src="statics/js/popper.min.js"></script>
		<script type="text/javascript" src="statics/js/bootstrap.js"></script>
		<script type="text/javascript" src="statics/js/bootstrap-datetimepicker.js"></script>
		<script type="text/javascript" src="statics/js/bootstrap-datetimepicker.zh-CN.js"></script>
	</head>

	<body>

		<div class="container">
				<h4 class="page-header">订单管理</h4>
			<form action="/selectOrderSheet" method="post">
				<div class="form-inline">

					<label for="customerName">客户姓名</label><input type="text" class="form-control" name="customerName" id="customerName">
					<label for="brand">汽车品牌</label><input type="text" class="form-control " name="brand" id="brand">
				</div>
				<div><button class="btn btn-default col-md-offset-4" type="submit">查询</button>
					<button class="btn btn-info col-md-offset-1" type="reset">重置</button>
				</div>
			</form>
		</div>

		<div class="container">
			<h4 class="center-block">订单信息</h4>

			<table class="table table-striped table-bordered table-hover table-condensed table-responsive" id="table">
				<tr class="success">
					<th>序号</th>
					<th>操作</th>
					<th>订单单号</th>
					<th>客户名称</th>
					<th>联系电话</th>
					<th>汽车品牌</th>
					<th>VIN</th>
					<th>车辆价格</th>
					<th>开单时间</th>
					<th>订单状态</th>
				</tr>
				<#list listlg as orderSheetVO>
				<tr>
					<td>${(orderSheetVO_index)+1}</td>
					<td>
						<a href="orderDetails?orderSheetId=${orderSheetVO.orderSheetId}"><button class="btn btn-info">详情</button></a>
						<a href="deleteOrderSheet?orderSheetId=${orderSheetVO.orderSheetId}" class="dele"><button class="btn btn-info">删除</button></a>
						<a href="submitOrderSheet?orderSheetId=${orderSheetVO.orderSheetId}" class="sub"><button class="btn btn-info">提交</button></a>
					</td>
					<td>${orderSheetVO.orderSheetId}</td>
					<td>${orderSheetVO.customerName}</td>
					<td>${orderSheetVO.customerTel}</td>
					<td>${orderSheetVO.brand}</td>
					<td>${orderSheetVO.vin}</td>
					<td>${orderSheetVO.price}</td>
					<td>${orderSheetVO.minopeningTime}</td>
					<td class="state">${orderSheetVO.orderState}</td>
				</tr>
				</#list>
			</table>

			<div class=" center-block">
				<button class="btn-info col-sm-1" onclick="javascript:selectOrder(1)">首页</button>
				<button class="btn-info col-sm-1" onclick="javascript:selectOrder(($('#thisPageNo').val()*1)-1)">上一页</button>
				<button class="btn-info col-sm-1" onclick="javascript:selectOrder(($('#thisPageNo').val()*1)+1)" >下一页</button>
				<button class="btn-info col-sm-1" onclick="javascript:selectOrder($('#thispageTotal').val()*1)">末页</button>
				共<input type="text" value="1" id="thisPageNo" style="width: 10px;border: none" readonly>/<input type="text" id="thispageTotal" value="${pageTotal}" style="width: 10px;border: none" readonly>页
				<span class="col-sm-1"></span></div>
				<input type="hidden" id="pageNo" value="1" name="pageNo">
		</div>
		<script type="text/javascript">
			/*分页及条件查询*/
			$(function(){
			    $(".state").each(function (index) {
					if($(this).html()!="已保存" && $(this).html()!="审核驳回"){
						$(this).parent().find(".dele").attr("hidden","hidden");
                        $(this).parent().find(".sub").attr("hidden","hidden");
					}
                })
			})
             function selectOrder(pageNo){
                    var customerName = $("#customerName").val();
                    var brand = $("#brand").val();
                    $.getJSON(
                        "nextPage",
                        {"pageNo":pageNo,"customerName":customerName,"brand":brand},
                        function(data){
                        	$("#table tr:not(:first)").remove();
                        	$(data.list).each(function(index,orderSheetVO){
                        	 var tr = "<tr><td>"+(index+1)+"</td>"+
                            "<td>"
                        	 +"<a href='orderDetails?orderSheetId="+orderSheetVO.orderSheetId+"'"+"><button class='btn btn-info'>详情</button></a>"
                        	 if(orderSheetVO.orderState =="已保存" || orderSheetVO.orderState == "审核驳回"){
                                 tr = tr  +"<a href='deleteOrderSheet?orderSheetId="+orderSheetVO.orderSheetId+"'"+"><button class='btn btn-info'>删除</button></a>"
                                     +"<a href='submitOrderSheet?orderSheetId="+orderSheetVO.orderSheetId+"'"+"><button class='btn btn-info'>提交</button></a></td>"
                             }
                                tr = tr +"<td>"+orderSheetVO.orderSheetId+"</td>"
                            +"<td>"+orderSheetVO.customerName+"</td>"
                            +"<td>"+orderSheetVO.customerTel+"</td>"
                            +"<td>"+orderSheetVO.brand+"</td>"
                            +"<td>"+orderSheetVO.vin+"</td>"
                            +"<td>"+orderSheetVO.price+"</td>"
                            +"<td>"+orderSheetVO.minopeningTime+"</td>"
                            +"<td>"+orderSheetVO.orderState+"</td></tr>"
                            $("#table").append(tr);
                        	})
                        	$("#thisPageNo").val(data.pageNo);
                            $("#thispageTotal").val(data.pageTotal);
                        }
                    )
               }
        </script>
</body>
</html>